Global $n$-compact Validation Engine

Tutorial: Lurch Node REPL

Lurch Node REPL

\lode is an instance of the node command line REPL which has all of the LDE commands and supporting utilities preloaded. This is useful for debugging and experimenting with the functions and classes defined in the repository. This initialized version of node can be thought of as Lurch node, or simply $\lode$ for short.

Running $\lode$

To run $\lode$ from the command line in a terminal from the src/experimental/ subfolder the command node lode. (If you have not yet set up a copy of this repository with the appropriate Node.js version installed, see our GitHub README, which explains how to do so.)

> node lode

Welcome to š•ƒš• š••š•– - the Lurch Node app
(type .help for help)
ā–¶ļøŽ 

You are now at the Lurch Node REPL command prompt. All of the exported modules in the src/index.js file in this repository and all of the utilities useful tools from the experimental folder are available at the $\lode$ prompt. For example, you can now do things like this (see LogicConcept and toPutdown):

Welcome to š•ƒš• š••š•– - the Lurch Node app
(type .help for help)
ā–¶ļøŽ LogicConcept.fromPutdown(`{ :Hello ( World ! ) }`)[0].toPutdown()
'{ :Hello (World !) }'
ā–¶ļøŽ

Since creating and viewing LogicConcepts in putdown notation is often what we want, $\lode$ provides a shortcut for constructing LCs and displays LCs in Putdown notation by default.

ā–¶ļøŽ LogicConcept.fromPutdown(`{ :Hello ( World ! ) }`)[0].toPutdown()
'{ :Hello (World !) }'
ā–¶ļøŽ lc(`{ :Hello ( World ! ) }`)  // constructs the same thing
{ :Hello (World !) }

There is also a more user friendly parser that supports features of asciimath http://asciimath.org. This allows you to construct LogicConstructs like this

ā–¶ļøŽ $(`forall x. 0 leq x  implies x^2+1 leq (x+1)^2`)
(āˆ€ x , (ā‡’ (< 0 x) (ā‰¤ (+ (^ x 2) 1) (^ (+ x 1) 2))))

and also accepts unicode input

ā–¶ļøŽ $(`āˆ€x. 0ā‰¤x ā‡’ x^2+1ā‰¤(x+1)^2`)
(āˆ€ x , (ā‡’ (< 0 x) (ā‰¤ (+ (^ x 2) 1) (^ (+ x 1) 2))))

If you validate a document in $\lode$ the result can be displayed in many different ways, including syntax highlighting.

To run the test suite simply type the command .test. This loads numerous example documents in the array acid.

ā–¶ļøŽ .test
Loading the acid tests ...

Parser Test: ā†’ ok
Test 0: (END Example 1) If Pā‡’Q then Ā¬PāˆØQ.
  Test 0.0 ā†’ ok
Test 1: (END Example 4) If āˆƒx,āˆ€y,Q(x,y) then āˆ€y,āˆƒx,Q(x,y)
  Test 1.0 ā†’ ok
     :
 (omitted)
     :
Test 22: Math 299 Midterm Exam Proofs 2023
  Test 22.0 ā†’ ok

50 tests passed - 0 tests failed

904 green checks
58 red marks
Test result stored in the array 'acid'

To view a document in various formats you can use the .report() command with various options (all)

ā–¶ļøŽ acid[1].report(user)
  {
42  (END Example 4) If āˆƒx,āˆ€y,Q(x,y) then āˆ€y,āˆƒx,Q(x,y)
43  {
      Thm 4: If āˆƒx,āˆ€y,Q(x,y) then āˆ€y,āˆƒx,Q(x,y)
      { :(āˆƒ x , (āˆ€ y , (Q x y))) (āˆ€ y , (āˆƒ x , (Q x y)))āœ”ļøŽ }āœ”ļøŽ
      Proof:
      {
        :(āˆƒ x , (āˆ€ y , (Q x y)))
        {
          :Let[z]
          ForSome[c , (āˆ€ y , (Q c y))]āœ”ļøŽ
          (Q c z)āœ”ļøŽ
          (āˆƒ x , (Q x z))āœ”ļøŽ
        }āœ”ļøŽ
        (āˆ€ y , (āˆƒ x , (Q x y)))āœ”ļøŽ
      }āœ”ļøŽ
    }āœ”ļøŽ
  }āœ”ļøŽ

You can use .list to see a list of current files and libraries and load a document with the commands loadDoc() and initialize().

ā–¶ļøŽ doc = loadDoc('proofs/math299/midterm')
{
  :Declare[šœ† āž¤]
  :Declare[and or ā‡’ ā‡” Ā¬ ā†’ā†]
  :Declare[āˆ€ āˆƒ āˆƒ! =]
  :Declare[0 Ļƒ + ā‹… ā‰¤]
  :Declare[1 2 3 4 5 | prime]
  :{ { :{ W V } (and W V) } { :(and W V) { W V } } }
  :{ { :{ :W V } (ā‡’ W V) } { :(ā‡’ W V) { :W V } } }
           :
       (omitted)
           :
          (ā‡’ (āˆ€ y , (Ā¬ (loves y s))) (āˆ€ y , (Ā¬ (loves s y))))āœ”ļøŽ
        }āœ”ļøŽ
        (āˆ€ x , (ā‡’ (āˆ€ y , (Ā¬ (loves y x))) (āˆ€ y , (Ā¬ (loves x y)))))āœ”ļøŽ
      }āœ”ļøŽ
    }āœ”ļøŽ
  }āœ”ļøŽ
}āœ”ļøŽ
  

The command .makedocs builds the jsdoc documentation for the experimental folder.

There are many other features available. You can type .features in $\lode$ to see the current list of features.